home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5853 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: howland.reston.ans.net!agate!tmonroe
  2. From: tmonroe@po.EECS.Berkeley.EDU (Tony Monroe)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: delete
  5. Date: 7 Feb 1996 05:23:27 GMT
  6. Organization: University of California, Berkeley
  7. Message-ID: <4f9d0f$o3e@agate.berkeley.edu>
  8. References: <DMDBqB.Bw5@undergrad.math.uwaterloo.ca>
  9. NNTP-Posting-Host: po.eecs.berkeley.edu
  10.  
  11. In article <DMDBqB.Bw5@undergrad.math.uwaterloo.ca>,
  12. Steve Kettle <sckettle@undergrad.math.uwaterloo.ca> wrote:
  13. > Is there anyway to force a deleted pointer to be zero or are we just
  14. > at mercy of the compiler implementation?
  15.  
  16. void f()
  17. {
  18.     Thing *foo;
  19.     foo = new Thing("blurfl");
  20.     //
  21.     // bunch o' code
  22.     //
  23.     delete foo;
  24.     foo = NULL;    // assuming #define NULL 0 or something equivalent
  25. }
  26.  
  27. Yes, it is up to the compiler.  Personally, I would not bet on the compiler
  28. zeroing the pointer for you.  Besides, playing with memory you don't have
  29. can be hazardous to your program's (or, in more extreme cases, computer's)
  30. health.
  31.  
  32. --
  33.              Tony Monroe              |
  34.       "Experimental Non-Rabbit"       |            This space for rent
  35.    tmonroe@cory.eecs.berkeley.edu     |       Unreasonable rates available
  36. http://www.csua.berkeley.edu/~tmonroe |
  37.